package com.yanqu.road.server.manger.activity.recycle;

import com.yanqu.road.entity.activity.ActivityInfo;
import com.yanqu.road.entity.activity.ActivityItemRecycleData;
import com.yanqu.road.entity.enums.eActivityType;
import com.yanqu.road.entity.player.UserBagItem;
import com.yanqu.road.server.manger.activity.ActivityMgr;
import com.yanqu.road.server.manger.activity.turtle.TurtleConfig;
import com.yanqu.road.server.manger.activity.turtle.TurtleMgr;

import java.util.ArrayList;

/**
 * @Author : Cxp
 * @Time : 2024-09-11
 * @Description : 乌龟对对碰-道具回收
 */

public class TurtleRecycleStrategy extends AbstractItemRecycleStrategy {

    @Override
    public void markNeedRecycleItem() {
        ActivityInfo activityInfo = TurtleMgr.getActivityInfo();
        if (ActivityMgr.activityInShowTime(activityInfo)) {
            long recycleTime = activityInfo.getEndShowTime() * 1000L + gapTime; // EndShowTime是秒级别的
            TurtleConfig config = TurtleMgr.getConfig();
            if (config != null) {
                ActivityItemRecycleMgr.addRecycleItemData(config.getItemId(), activityType, 0, recycleTime, new ArrayList<>());
                ActivityItemRecycleMgr.addRecycleItemData(config.getScoreId(), activityType, 0, recycleTime, new ArrayList<>());
                ActivityItemRecycleMgr.addRecycleItemData(config.getGoldId(), activityType, 0, recycleTime, new ArrayList<>());
                ActivityItemRecycleMgr.addRecycleItemData(config.getSilverId(), activityType, 0, recycleTime, new ArrayList<>());
                ActivityItemRecycleMgr.addRecycleItemData(config.getDollId(), activityType, 0, recycleTime, new ArrayList<>());
            }
        }
    }

    @Override
    protected void initActivityType() {
        activityType = eActivityType.Turtle.getValue();
    }

    @Override
    protected void doRecycle(long userId, ActivityItemRecycleData data) {
        if (data.getRecycleType() == 0) {
            UserBagItem userBagItem = getUserBagItem(userId, data.getItemId());
            if (userBagItem != null && userBagItem.getNum() > 0) {
                removeItem(userBagItem);
            }
        }
    }

    @Override
    public boolean isActivityRunning() {
        return false;
    }
}
